<template>
	<view class="box">
		<view class="li" v-for="(item,i) in contentarr">
			<view class="title">
				<view class="l">
					{{i<10?`0${i+1}`:i+1}}
				</view>
				<view class="r">
					{{item.title}}
				</view>
			</view>
			<view class="content">
				<rich-text :nodes="item.content" ></rich-text>
			</view>


		</view>
	</view>
</template>

<script>
	import {
		UserApi
	} from '@/api';
	export default {
		data() {
			return {
				contentarr: [],
				p: 1
			};
		},
		onLoad() {
			this.getProblem()
		},
		methods: {
			async getProblem(bol = true) {
				try {
					if (bol) this.p = 1
					const res = await UserApi.getProblem({
						p: this.p,
						size: 10
					})
					if (bol)
						return this.contentarr = res.result.rows
					this.contentarr.push(...res.result.rows)
				} catch (e) {
					//TODO handle the exception
				}
			}
		},
		onReachBottom() {
			this.p += 1
			this.getProblem(false)
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		padding: 30rpx;
		width: 100vw;
		box-sizing: border-box;

		.li {
			width: 690rpx;
			border-radius: 12rpx;
			background: #ffffff;
			padding: 25rpx;
			box-sizing: border-box;
			margin-bottom: 30rpx;

			.content {
				text-align: left;
				font-size: 28rpx;
				font-weight: 400;
			}

			.title {
				display: flex;
				align-items: center;
				margin-bottom: 25rpx;

				.l {
					margin-right: 5rpx;
					width: 35rpx;
					height: 35rpx;
					line-height: 35rpx;
					opacity: 1;
					background: #fb8b07;
					color: #ffffff;
					text-align: center;
					font-size: 22rpx;
					font-weight: 400;
				}
			}
		}

	}
</style>